Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Interface for fake-rs #209

Merged
merged 8 commits into from
Dec 22, 2024
Merged

CLI Interface for fake-rs #209

merged 8 commits into from
Dec 22, 2024

Conversation

akhildevelops
Copy link
Contributor

This Pr powers fake-rs to generate fake data from CLI.
Features:

  • Name, FirstName, CityPrefix, Password can be generated.
  • locale and no: of repeatitions can be sent as parameters to CLI.

Below are few examples:

  • Help Message display
❯ ./fake --help
An easy to use library and command line for generating fake data like name, number, address, lorem, dates, etc.

Usage: fake [OPTIONS] [COMMAND]

Commands:
  Name        
  FirstName   
  CityPrefix  
  Password    
  help        Print this message or the help of the given subcommand(s)

Options:
  -r, --repeat <repeat>  [default: 1]
  -l, --locale <locale>  [default: EN]
  -h, --help             Print help
  -V, --version          Print version

  • Generate random name defaults to EN locale
❯ ./fake Name
Generating 1 fakes for EN locale
Theresa Walker

  • Generate 5 chinese random names
❯ ./fake -r5 -lzh_cn Name
Generating 5 fakes for ZH_CN locale
何丹华
尹雅瑾
于金福
郭雨珍
龙菲霞

  • Generate 5 random passwords with minimum 10 characters
❯ ./fake -r5 Password --min 10
Generating 5 fakes for EN locale
Q6eeXHfC3uzSRqtZwB
6fDHAOh3I7Ah77duLL
R8ygoTLmd4i1z1Z
5Uxj3RdEK5O4Af3ow
2XWsGT0lUaDnMZTb7

Arguments can be sent to fake generators like password that accept different ranges

❯ ./fake Password --help
Usage: fake Password [OPTIONS]

Options:
      --max <max>  [default: 20]
      --min <min>  [default: 10]
  -h, --help       Print help

@akhildevelops
Copy link
Contributor Author

Hi @cksac, Gave a pr for CLI implementation. Let me know if the code design is good and I'll implement for other fake generators. currently it supports

  Name        
  FirstName   
  CityPrefix  
  Password

Copy link
Owner

@cksac cksac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, thx

fake/Cargo.toml Outdated Show resolved Hide resolved
@akhildevelops
Copy link
Contributor Author

❯ ./fake 
An easy to use library and command line for generating fake data like name, number, address, lorem, dates, etc.

Usage: fake [OPTIONS] [COMMAND]

Commands:
  CityPrefix            
  CitySuffix            
  CityName              
  CountryName           
  CountryCode           
  StreetSuffix          
  StreetName            
  TimeZone              
  StateName             
  StateAbbr             
  SecondaryAddressType  
  SecondaryAddress      
  ZipCode               
  PostCode              
  BuildingNumber        
  Latitude              
  Longitude             
  Geohash               
  Isbn                  
  Isbn10                
  Isbn13                
  CreditCardNumber      
  CompanySuffix         
  CompanyName           
  Buzzword              
  BuzzwordMiddle        
  BuzzwordTail          
  CatchPhrase           
  BsVerb                
  BsAdj                 
  BsNoun                
  Bs                    
  Profession            
  Industry              
  FreeEmailProvider     
  DomainSuffix          
  FreeEmail             
  SafeEmail             
  Username              
  Password              
  IPv4                  
  IPv6                  
  IP                    
  MACAddress            
  UserAgent             
  Seniority             
  Field                 
  Position              
  Word                  
  Words                 
  Sentence              
  Sentences             
  Paragraph             
  Paragraphs            
  FirstName             
  LastName              
  Title                 
  Suffix                
  Name                  
  NameWithTitle         
  PhoneNumber           
  CellNumber            
  FilePath              
  FileName              
  FileExtension         
  DirPath               
  MimeType              
  Semver                
  SemverStable          
  SemverUnstable        
  CurrencyCode          
  CurrencyName          
  CurrencySymbol        
  Bic                   
  Isin                  
  help                  Print this message or the help of the given subcommand(s)

Options:
  -r, --repeat <repeat>  [default: 1]
  -l, --locale <locale>  [default: EN]
  -h, --help             Print help
  -V, --version          Print version

Now it supports many subcommands, still there are few pending that are bit tricky to expand them in macros.

HealthCode / LicensePlat supports only one kind of locale.
NumberWithFormat<'a>(fmt: &'a str) that has lifetime argument.

I'll try to add remaining too in a while but for now will take a break. You can merge if everything looks good.

@cksac cksac merged commit 1fd56e0 into cksac:master Dec 22, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants